function policy_effects = policy_effects_counter2(data_counterfactual,data_baseline,fp)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%;
%Compute Policy Effects (baseline vs. counterfactual) of Policy #2 with
%endogenous moving of receiving parents;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%;

data_skills_movers_base    = NaN(1,fp.n_rip_sim);
data_skills_movers_counter = NaN(1,fp.n_rip_sim);

data_skills_receivers_base    = NaN(1,fp.n_rip_sim);
data_skills_receivers_counter = NaN(1,fp.n_rip_sim);

data_PS_movers_base    = NaN(1,fp.n_rip_sim);
data_PS_movers_counter = NaN(1,fp.n_rip_sim);

data_PS_receivers_base    = NaN(1,fp.n_rip_sim);
data_PS_receivers_counter = NaN(1,fp.n_rip_sim);

data_inv_movers_base      = NaN(1,fp.n_rip_sim);
data_inv_movers_counter   = NaN(1,fp.n_rip_sim);

data_inv_receivers_base    = NaN(1,fp.n_rip_sim);
data_inv_receivers_counter = NaN(1,fp.n_rip_sim);

for h = 1:1:fp.n_rip_sim  
            
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%;
    %Movers;
    %%%%%%%%%%%%%%%%%%%%%%%%%%;
    
    %%%%%%%%%%%%%
    %Baseline;   
    %%%%%%%%%%%%%
    
    data_baseline_origin = data_baseline{fp.origin_neigh};    
    
    %a) Skills;
    skills_children_T = data_baseline_origin(  data_baseline_origin(:,fp.ind_data.child_age,h)==11 , fp.ind_data.child_C_tp1 , h ) ;    
    data_skills_movers_base(1,h) =   nanmean(log(  skills_children_T(fp.id_moved_children(:,h)==1)  ) ) ;     


    %%%%%%%%%%%%%%%%%%
    %Counterfactual (movers=1);
    %%%%%%%%%%%%%%%%%%
    
    %a) Skills;    
    skills_children_T = data_counterfactual( data_counterfactual(:,fp.ind_data.child_age,h)==11 & data_counterfactual(:,fp.ind_data.moved,h)==1, fp.ind_data.child_C_tp1 , h ) ;    
    data_skills_movers_counter(1,h) =  nanmean( log(  skills_children_T ) );         
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%;
    %Receivers;
    %%%%%%%%%%%%%%%%%%%%%%%%%%;
    
    %%%%%%%%%%%%%%%%%%
    %Baseline;    
    %%%%%%%%%%%%%%%%%%
    data_baseline_receiving = data_baseline{fp.receiving_neigh};       
    
    %a) Skills;
    skills_children_T = data_baseline_receiving(  data_baseline_receiving(:,fp.ind_data.child_age,h)==11 , fp.ind_data.child_C_tp1 , h ) ;        
    data_skills_receivers_base(1,h) = nanmean(log( skills_children_T(fp.id_flights(:,h)==0)  ) ) ;             
    
    %%%%%%%%%%%%%%%%%%
    %Counterfactual (movers=0);
    %%%%%%%%%%%%%%%%%%
    
    %a) Skills;    
    skills_children_T = data_counterfactual( data_counterfactual(:,fp.ind_data.child_age,h)==11 & data_counterfactual(:,fp.ind_data.moved,h)==0, fp.ind_data.child_C_tp1 , h ) ;    
    data_skills_receivers_counter(1,h) =  nanmean( log(  skills_children_T(fp.id_flights(:,h)==0) ) );     
        
        
end


policy_effects.pe_skills_moved     = nanmean( data_skills_movers_counter - data_skills_movers_base ) ;
policy_effects.pe_skills_receiving = nanmean( data_skills_receivers_counter - data_skills_receivers_base ) ;


  